package com.yu.crm.service.impl;

import com.yu.crm.domain.pojo.CrmCar;
import com.yu.crm.domain.response.UserCarRep;
import com.yu.crm.mapper.CrmCarMapper;
import com.yu.crm.service.ICrmCarService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yxzz.common.helper.DataHelpers;
import org.springframework.stereotype.Service;


import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author neo
 * @since 2020-07-21
 */
@Service
public class CrmCarService extends ServiceImpl<CrmCarMapper, CrmCar> implements ICrmCarService {
    @Override
    public void addOrUpdate(CrmCar car){
        if(DataHelpers.isNotEmpty(car.getId())){
            car.setGmtModified(LocalDateTime.now());
            this.updateById(car);
        }else{
            car.setGmtCreate(LocalDateTime.now());
            car.setGmtModified(LocalDateTime.now());
            this.save(car);
        }
    }

    @Override
    public List<UserCarRep> getAllUser(){
           return  baseMapper.getAllUser();
    }
}
